<?xml version="1.0" encoding="UTF-8"?>

<!-- edited with XML Spy v4.4 U (http://www.xmlspy.com) by Dmitry Gribov (DDS) -->

<xs:schema targetNamespace="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:genre="http://www.gribuser.ru/xml/fictionbook/2.0/genres" elementFormDefault="qualified" attributeFormDefault="unqualified">

  <xs:import namespace="http://www.w3.org/1999/xlink" schemaLocation="FictionBookLinks.xsd"/>

  <xs:import namespace="http://www.gribuser.ru/xml/fictionbook/2.0/genres" schemaLocation="FictionBookGenres.xsd"/>

  <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="FictionBookLang.xsd"/>

  <xs:element name="FictionBook">

    <xs:annotation>

      <xs:documentation>Root element</xs:documentation>

    </xs:annotation>

    <xs:complexType>

      <xs:sequence>

        <xs:element name="stylesheet" minOccurs="0" maxOccurs="unbounded">

          <xs:annotation>

            <xs:documentation>This element contains an arbitrary stylesheet that is intepreted by a some processing programs, e.g. text/css stylesheets can be used by XSLT stylesheets to generate better looking html</xs:documentation>

          </xs:annotation>

          <xs:complexType>

            <xs:simpleContent>

              <xs:extension base="xs:string">

                <xs:attribute name="type" type="xs:string" use="required"/>

              </xs:extension>

            </xs:simpleContent>

          </xs:complexType>

        </xs:element>

        <xs:element name="description">

          <xs:complexType>

            <xs:sequence>

              <xs:element name="title-info">

                <xs:annotation>

                  <xs:documentation>Generic information about the book</xs:documentation>

                </xs:annotation>

                <xs:complexType>

                  <xs:sequence>

                    <xs:element name="genre" maxOccurs="unbounded">

                      <xs:annotation>

                        <xs:documentation>Genre of this book, with the optional match percentage</xs:documentation>

                      </xs:annotation>

                      <xs:complexType>

                        <xs:simpleContent>

                          <xs:extension base="genre:genreType">

                            <xs:attribute name="match" type="xs:integer" use="optional" default="100"/>

                          </xs:extension>

                        </xs:simpleContent>

                      </xs:complexType>

                    </xs:element>

                    <xs:element name="author" maxOccurs="unbounded">

                      <xs:annotation>

                        <xs:documentation>Author(s) of this book</xs:documentation>

                      </xs:annotation>

                      <xs:complexType>

                        <xs:complexContent>

                          <xs:extension base="authorType"/>

                        </xs:complexContent>

                      </xs:complexType>

                    </xs:element>

                    <xs:element name="book-title" type="textFieldType">

                      <xs:annotation>

                        <xs:documentation>Book title</xs:documentation>

                      </xs:annotation>

                    </xs:element>

                    <xs:element name="annotation" type="annotationType" minOccurs="0">

                      <xs:annotation>

                        <xs:documentation>Annotation for this book</xs:documentation>

                      </xs:annotation>

                    </xs:element>

                    <xs:element name="keywords" type="textFieldType" minOccurs="0">

                      <xs:annotation>

                        <xs:documentation>Any keywords for this book, intended for use in search engines</xs:documentation>

                      </xs:annotation>

                    </xs:element>

                    <xs:element name="date" type="dateType" minOccurs="0">

                      <xs:annotation>

                        <xs:documentation>Date this book was written, can be not exact, e.g. 1863-1867. If an optional attribute is present, then it should contain some computer-readable date from the interval for use by search and indexingengines</xs:documentation>

                      </xs:annotation>

                    </xs:element>

                    <xs:element name="coverpage" minOccurs="0">

                      <xs:annotation>

                        <xs:documentation>Any coverpage items, currently only images</xs:documentation>

                      </xs:annotation>

                      <xs:complexType>

                        <xs:sequence>

                          <xs:element name="image" type="imageType" maxOccurs="unbounded"/>

                        </xs:sequence>

                      </xs:complexType>

                    </xs:element>

                    <xs:element name="lang" type="xs:language"/>

                    <xs:element name="src-lang" type="xs:language" minOccurs="0">

                      <xs:annotation>

                        <xs:documentation>Book's source language if this is a translation</xs:documentation>

                      </xs:annotation>

                    </xs:element>

                    <xs:element name="translator" type="authorType" minOccurs="0" maxOccurs="unbounded">

                      <xs:annotation>

                        <xs:documentation>Translators if this is a translation</xs:documentation>

                      </xs:annotation>

                    </xs:element>

                    <xs:element name="sequence" type="sequenceType" minOccurs="0" maxOccurs="unbounded">

                      <xs:annotation>

                        <xs:documentation>Any sequences this book might be part of</xs:documentation>

                      </xs:annotation>

                    </xs:element>

                  </xs:sequence>

                </xs:complexType>

              </xs:element>

              <xs:element name="document-info">

                <xs:annotation>

                  <xs:documentation>Information about this particular (xml) document</xs:documentation>

                </xs:annotation>

                <xs:complexType>

                  <xs:sequence>

                    <xs:element name="author" type="authorType" maxOccurs="unbounded">

                      <xs:annotation>

                        <xs:documentation>Author(s) of this particular document</xs:documentation>

                      </xs:annotation>

                    </xs:element>

                    <xs:element name="program-used" type="textFieldType" minOccurs="0">

                      <xs:annotation>

                        <xs:documentation>Any software used in preparation of this document, in free format</xs:documentation>

                      </xs:annotation>

                    </xs:element>

                    <xs:element name="date" type="dateType">

                      <xs:annotation>

                        <xs:documentation>Date this document was created, same guidelines as in the &lt;title-info&gt; section apply</xs:documentation>

                      </xs:annotation>

                    </xs:element>

                    <xs:element name="src-url" type="xs:string" minOccurs="0" maxOccurs="unbounded">

                      <xs:annotation>

                        <xs:documentation>Source URL if this document is a conversion of some other (online) document</xs:documentation>

                      </xs:annotation>

                    </xs:element>

                    <xs:element name="src-ocr" type="textFieldType" minOccurs="0">

                      <xs:annotation>

                        <xs:documentation>Author of the original (online) document, if this is a conversion</xs:documentation>

                      </xs:annotation>

                    </xs:element>

                    <xs:element name="id" type="xs:token">

                      <xs:annotation>

                        <xs:documentation>this is a unique identifier for a document. this must not change unless you make substantial updates to the document</xs:documentation>

                      </xs:annotation>

                    </xs:element>

                    <xs:element name="version" type="xs:float">

                      <xs:annotation>

                        <xs:documentation>Document version, in free format, should be incremented if the document is changed and re-released to the public</xs:documentation>

                      </xs:annotation>

                    </xs:element>

                    <xs:element name="history" type="annotationType" minOccurs="0"/>

                  </xs:sequence>

                </xs:complexType>

              </xs:element>

              <xs:element name="publish-info" minOccurs="0">

                <xs:annotation>

                  <xs:documentation>Information about some paper/outher published document, that was used as a source of this xml document</xs:documentation>

                </xs:annotation>

                <xs:complexType>

                  <xs:sequence>

                    <xs:element name="book-name" type="textFieldType" minOccurs="0">

                      <xs:annotation>

                        <xs:documentation>Original (paper) book name</xs:documentation>

                      </xs:annotation>

                    </xs:element>

                    <xs:element name="publisher" type="textFieldType" minOccurs="0">

                      <xs:annotation>

                        <xs:documentation>Original (paper) book publisher</xs:documentation>

                      </xs:annotation>

                    </xs:element>

                    <xs:element name="city" type="textFieldType" minOccurs="0">

                      <xs:annotation>

                        <xs:documentation>City where the original (paper) book was published</xs:documentation>

                      </xs:annotation>

                    </xs:element>

                    <xs:element name="year" type="xs:gYear" minOccurs="0">

                      <xs:annotation>

                        <xs:documentation>Year of the original (paper) publication</xs:documentation>

                      </xs:annotation>

                    </xs:element>

                    <xs:element name="isbn" type="textFieldType" minOccurs="0"/>

                    <xs:element name="sequence" type="sequenceType" minOccurs="0" maxOccurs="unbounded"/>

                  </xs:sequence>

                </xs:complexType>

              </xs:element>

              <xs:element name="custom-info" minOccurs="0" maxOccurs="unbounded">

                <xs:annotation>

                  <xs:documentation>Any other information about the book/document that didnt fit in the above groups</xs:documentation>

                </xs:annotation>

                <xs:complexType>

                  <xs:simpleContent>

                    <xs:extension base="textFieldType">

                      <xs:attribute name="info-type" type="xs:string" use="required"/>

                    </xs:extension>

                  </xs:simpleContent>

                </xs:complexType>

              </xs:element>

            </xs:sequence>

          </xs:complexType>

        </xs:element>

        <xs:element name="body" maxOccurs="unbounded">

          <xs:annotation>

            <xs:documentation>Main content of the book, multiple bodies are used for additional information, like footnotes, that do not appear in the main book flow. The first body is presented to the reader by default, and content in the other bodies should be accessible by hyperlinks. Name attribute should describe the meaning of this body, this is optional for the main body.</xs:documentation>

          </xs:annotation>

          <xs:complexType>

            <xs:sequence>

              <xs:element name="image" type="imageType" minOccurs="0">

                <xs:annotation>

                  <xs:documentation>Image to be displayed at the top of this section</xs:documentation>

                </xs:annotation>

              </xs:element>

              <xs:element name="title" type="titleType" minOccurs="0">

                <xs:annotation>

                  <xs:documentation>A fancy title for the entire book, should be used if the simple text version in &lt;description&gt; is not adequate, e.g. the book title has multiple paragraphs and/or character styles</xs:documentation>

                </xs:annotation>

              </xs:element>

              <xs:element name="epigraph" type="epigraphType" minOccurs="0" maxOccurs="unbounded">

                <xs:annotation>

                  <xs:documentation>Epigraph(s) for the entire book, if any</xs:documentation>

                </xs:annotation>

              </xs:element>

              <xs:element name="section" type="sectionType" maxOccurs="unbounded"/>

            </xs:sequence>

            <xs:attribute name="name" type="xs:string" use="optional"/>

            <xs:attribute ref="xml:lang"/>

          </xs:complexType>

        </xs:element>

        <xs:element name="binary" minOccurs="0" maxOccurs="unbounded">

          <xs:annotation>

            <xs:documentation>Any binary data that is required for the presentation of this book in base64 format. Currently only images are used.</xs:documentation>

          </xs:annotation>

          <xs:complexType>

            <xs:simpleContent>

              <xs:extension base="xs:base64Binary">

                <xs:attribute name="content-type" type="xs:string" use="required"/>

                <xs:attribute name="id" type="xs:ID" use="required"/>

              </xs:extension>

            </xs:simpleContent>

          </xs:complexType>

        </xs:element>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:complexType name="authorType">

    <xs:annotation>

      <xs:documentation>Information about a single author</xs:documentation>

    </xs:annotation>

    <xs:choice>

      <xs:sequence>

        <xs:element name="first-name" type="textFieldType"/>

        <xs:element name="middle-name" type="textFieldType" minOccurs="0"/>

        <xs:element name="last-name" type="textFieldType"/>

        <xs:element name="nickname" type="textFieldType" minOccurs="0"/>

        <xs:element name="home-page" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>

        <xs:element name="email" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>

      </xs:sequence>

      <xs:sequence>

        <xs:element name="nickname" type="textFieldType"/>

        <xs:element name="home-page" type="xs:string" minOccurs="0"/>

        <xs:element name="email" type="xs:string" minOccurs="0"/>

      </xs:sequence>

    </xs:choice>

  </xs:complexType>

  <xs:complexType name="textFieldType">

    <xs:simpleContent>

      <xs:extension base="xs:string">

        <xs:attribute ref="xml:lang"/>

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>

  <xs:complexType name="dateType">

    <xs:annotation>

      <xs:documentation>A human readable date, maybe not exact, with an optional computer readable variant</xs:documentation>

    </xs:annotation>

    <xs:simpleContent>

      <xs:extension base="xs:string">

        <xs:attribute name="value" type="xs:date" use="optional"/>

        <xs:attribute ref="xml:lang"/>

      </xs:extension>

    </xs:simpleContent>

  </xs:complexType>

  <xs:complexType name="titleType">

    <xs:annotation>

      <xs:documentation>A title, used in sections, poems and body elements</xs:documentation>

    </xs:annotation>

    <xs:choice minOccurs="0" maxOccurs="unbounded">

      <xs:element name="p" type="pType"/>

      <xs:element name="empty-line"/>

    </xs:choice>

    <xs:attribute ref="xml:lang"/>

  </xs:complexType>

  <xs:complexType name="imageType">

    <xs:annotation>

      <xs:documentation>An empty element with an image name as an attribute</xs:documentation>

    </xs:annotation>

    <xs:attribute ref="xlink:type"/>

    <xs:attribute ref="xlink:href"/>

    <xs:attribute name="alt" type="xs:string" use="optional"/>

  </xs:complexType>

  <xs:complexType name="pType" mixed="true">

    <xs:annotation>

      <xs:documentation>A basic paragraph, may include simple formatting inside</xs:documentation>

    </xs:annotation>

    <xs:complexContent mixed="true">

      <xs:extension base="styleType">

        <xs:attribute name="id" type="xs:ID" use="optional"/>

        <xs:attribute name="style" type="xs:string" use="optional"/>

      </xs:extension>

    </xs:complexContent>

  </xs:complexType>

  <xs:complexType name="citeType">

    <xs:annotation>

      <xs:documentation>A citation with an optional citation author at the end</xs:documentation>

    </xs:annotation>

    <xs:sequence>

      <xs:choice minOccurs="0" maxOccurs="unbounded">

        <xs:element name="p" type="pType"/>

        <xs:element name="poem" type="poemType"/>

        <xs:element name="empty-line"/>

      </xs:choice>

      <xs:element name="text-author" type="textFieldType" minOccurs="0" maxOccurs="unbounded"/>

    </xs:sequence>

    <xs:attribute name="id" type="xs:ID" use="optional"/>

    <xs:attribute ref="xml:lang"/>

  </xs:complexType>

  <xs:complexType name="poemType">

    <xs:annotation>

      <xs:documentation>A poem</xs:documentation>

    </xs:annotation>

    <xs:sequence>

      <xs:element name="title" type="titleType" minOccurs="0">

        <xs:annotation>

          <xs:documentation>Poem title</xs:documentation>

        </xs:annotation>

      </xs:element>

      <xs:element name="epigraph" type="epigraphType" minOccurs="0" maxOccurs="unbounded">

        <xs:annotation>

          <xs:documentation>Poem epigraph(s), if any</xs:documentation>

        </xs:annotation>

      </xs:element>

      <xs:element name="stanza" maxOccurs="unbounded">

        <xs:annotation>

          <xs:documentation>Each poem should have at least one stanza. Stanzas are usually separated with empty lines by user agents.</xs:documentation>

        </xs:annotation>

        <xs:complexType>

          <xs:sequence>

            <xs:element name="title" type="titleType" minOccurs="0"/>

            <xs:element name="subtitle" type="pType" minOccurs="0"/>

            <xs:element name="v" type="pType" maxOccurs="unbounded">

              <xs:annotation>

                <xs:documentation>An individual line in a stanza</xs:documentation>

              </xs:annotation>

            </xs:element>

          </xs:sequence>

          <xs:attribute ref="xml:lang"/>

        </xs:complexType>

      </xs:element>

      <xs:element name="text-author" type="textFieldType" minOccurs="0" maxOccurs="unbounded"/>

      <xs:element name="date" type="dateType" minOccurs="0">

        <xs:annotation>

          <xs:documentation>Date this poem was written.</xs:documentation>

        </xs:annotation>

      </xs:element>

    </xs:sequence>

    <xs:attribute name="id" type="xs:ID" use="optional"/>

    <xs:attribute ref="xml:lang"/>

  </xs:complexType>

  <xs:complexType name="epigraphType">

    <xs:annotation>

      <xs:documentation>An epigraph</xs:documentation>

    </xs:annotation>

    <xs:sequence>

      <xs:choice minOccurs="0" maxOccurs="unbounded">

        <xs:element name="p" type="pType"/>

        <xs:element name="poem" type="poemType"/>

        <xs:element name="cite" type="citeType"/>

        <xs:element name="empty-line"/>

      </xs:choice>

      <xs:element name="text-author" type="textFieldType" minOccurs="0" maxOccurs="unbounded"/>

    </xs:sequence>

    <xs:attribute name="id" type="xs:ID" use="optional"/>

  </xs:complexType>

  <xs:complexType name="annotationType">

    <xs:annotation>

      <xs:documentation>A cut-down version of &lt;section&gt; used in annotations</xs:documentation>

    </xs:annotation>

    <xs:choice minOccurs="0" maxOccurs="unbounded">

      <xs:element name="p" type="pType"/>

      <xs:element name="poem" type="poemType"/>

      <xs:element name="cite" type="citeType"/>

      <xs:element name="empty-line"/>

    </xs:choice>

    <xs:attribute name="id" type="xs:ID" use="optional"/>

    <xs:attribute ref="xml:lang"/>

  </xs:complexType>

  <xs:complexType name="sectionType">

    <xs:annotation>

      <xs:documentation>A basic block of a book, can contain more child sections or textual content</xs:documentation>

    </xs:annotation>

    <xs:sequence minOccurs="0">

      <xs:element name="title" type="titleType" minOccurs="0">

        <xs:annotation>

          <xs:documentation>Section's title</xs:documentation>

        </xs:annotation>

      </xs:element>

      <xs:element name="epigraph" type="epigraphType" minOccurs="0" maxOccurs="unbounded">

        <xs:annotation>

          <xs:documentation>Epigraph(s) for this section</xs:documentation>

        </xs:annotation>

      </xs:element>

      <xs:element name="image" type="imageType" minOccurs="0">

        <xs:annotation>

          <xs:documentation>Image to be displayed at the top of this section</xs:documentation>

        </xs:annotation>

      </xs:element>

      <xs:element name="annotation" type="annotationType" minOccurs="0">

        <xs:annotation>

          <xs:documentation>Annotation for this section, if any</xs:documentation>

        </xs:annotation>

      </xs:element>

      <xs:choice>

        <xs:sequence>

          <xs:element name="section" type="sectionType" maxOccurs="unbounded">

            <xs:annotation>

              <xs:documentation>Child sections</xs:documentation>

            </xs:annotation>

          </xs:element>

        </xs:sequence>

        <xs:sequence>

          <xs:choice>

            <xs:element name="p" type="pType"/>

            <xs:element name="poem" type="poemType"/>

            <xs:element name="subtitle" type="pType"/>

            <xs:element name="cite" type="citeType"/>

            <xs:element name="empty-line"/>

            <xs:element name="table" type="tableType"/>

          </xs:choice>

          <xs:choice minOccurs="0" maxOccurs="unbounded">

            <xs:element name="p" type="pType"/>

            <xs:element name="image" type="imageType"/>

            <xs:element name="poem" type="poemType"/>

            <xs:element name="subtitle" type="pType"/>

            <xs:element name="cite" type="citeType"/>

            <xs:element name="empty-line"/>

            <xs:element name="table" type="tableType"/>

          </xs:choice>

        </xs:sequence>

      </xs:choice>

    </xs:sequence>

    <xs:attribute name="id" type="xs:ID" use="optional"/>

    <xs:attribute ref="xml:lang"/>

  </xs:complexType>

  <xs:complexType name="styleType" mixed="true">

    <xs:annotation>

      <xs:documentation>Markup</xs:documentation>

    </xs:annotation>

    <xs:choice minOccurs="0" maxOccurs="unbounded">

      <xs:element name="strong" type="styleType"/>

      <xs:element name="emphasis" type="styleType"/>

      <xs:element name="style" type="namedStyleType"/>

      <xs:element name="a" type="linkType"/>

      <xs:element name="image" type="imageType"/>

    </xs:choice>

    <xs:attribute ref="xml:lang"/>

  </xs:complexType>

  <xs:complexType name="namedStyleType" mixed="true">

    <xs:annotation>

      <xs:documentation>Markup</xs:documentation>

    </xs:annotation>

    <xs:choice minOccurs="0" maxOccurs="unbounded">

      <xs:element name="strong" type="styleType"/>

      <xs:element name="emphasis" type="styleType"/>

      <xs:element name="style" type="namedStyleType"/>

      <xs:element name="a" type="linkType"/>

      <xs:element name="image" type="imageType"/>

    </xs:choice>

    <xs:attribute ref="xml:lang"/>

    <xs:attribute name="name" type="xs:token" use="required"/>

  </xs:complexType>

  <xs:complexType name="linkType" mixed="true">

    <xs:annotation>

      <xs:documentation>Generic hyperlinks. Cannot be nested. Footnotes should be implemented by links referring to additional bodies in the same document</xs:documentation>

    </xs:annotation>

    <xs:choice minOccurs="0" maxOccurs="unbounded">

      <xs:element name="strong" type="styleLinkType"/>

      <xs:element name="emphasis" type="styleLinkType"/>

      <xs:element name="style" type="styleLinkType"/>

    </xs:choice>

    <xs:attribute ref="xlink:type" use="optional"/>

    <xs:attribute ref="xlink:href" use="required"/>

    <xs:attribute name="type" type="xs:token" use="optional"/>

  </xs:complexType>

  <xs:complexType name="styleLinkType" mixed="true">

    <xs:annotation>

      <xs:documentation>Markup</xs:documentation>

    </xs:annotation>

    <xs:choice minOccurs="0" maxOccurs="unbounded">

      <xs:element name="strong" type="styleLinkType"/>

      <xs:element name="emphasis" type="styleLinkType"/>

      <xs:element name="style" type="styleLinkType"/>

    </xs:choice>

  </xs:complexType>

  <xs:complexType name="sequenceType">

    <xs:annotation>

      <xs:documentation>Book sequences</xs:documentation>

    </xs:annotation>

    <xs:sequence>

      <xs:element name="sequence" type="sequenceType" minOccurs="0" maxOccurs="unbounded"/>

    </xs:sequence>

    <xs:attribute name="name" type="xs:string" use="required"/>

    <xs:attribute name="number" type="xs:integer" use="optional"/>

    <xs:attribute ref="xml:lang"/>

  </xs:complexType>

  <xs:complexType name="tableType">

    <xs:annotation>

      <xs:documentation>Basic html-like tables</xs:documentation>

    </xs:annotation>

    <xs:sequence>

      <xs:element name="tr" maxOccurs="unbounded">

        <xs:complexType>

          <xs:sequence>

            <xs:element name="td" type="pType" maxOccurs="unbounded"/>

          </xs:sequence>

          <xs:attribute name="align" type="alignType" use="optional" default="left"/>

        </xs:complexType>

      </xs:element>

    </xs:sequence>

  </xs:complexType>

  <xs:simpleType name="alignType">

    <xs:restriction base="xs:token">

      <xs:enumeration value="left"/>

      <xs:enumeration value="right"/>

      <xs:enumeration value="center"/>

    </xs:restriction>

  </xs:simpleType>

</xs:schema>